import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 98152
 * Date: 2024-10-30
 * Time: 19:52
 */
public class Test3 {
    public boolean IsContinuous (int[] numbers) {
        // write code here
        boolean flag = true;

        //1.将数组按照升序排序
        Arrays.sort(numbers);

        //2.计算数组中0的个数
        int count = 0;//记录0的个数
        for(int i = 0; i < 4; i++) {
            if(numbers[i] == 0) {
                count++;
            }else {
                break;
            }
        }

        //3. 将count个0改成所需要的数字
        int j = 0;
        int i = count;
        while(i < 4 && count > 0) {
            int tmp = numbers[i+1]-numbers[i] - 1;
            if(tmp > count) {
                return false;
            }
            while(tmp > 0) {
                numbers[j++] = numbers[i] + tmp;
                //i = j-1;
                count--;
                tmp--;
            }
            i++;
        }

        //4.再次排序，看是否是顺子
        Arrays.sort(numbers);
        for(i = 0; i < 4; i++) {
            if(numbers[i] != 0 && numbers[i] + 1 != numbers[i+1]) {
                flag = false;
                break;
            }
        }
        return flag;
    }
}
